<template>
  <div>
    <div class="input" style="padding: 50px 0px">
      <van-form @submit="onSubmit">
        <van-cell-group inset>
          <van-field
            v-model="value"
            label="密码"
            placeholder="至少6位,包含数字,大小写字母"
          />
        </van-cell-group>
        <div style="margin: 80px 10px">
          <van-button round block type="primary" native-type="submit">
            完成
          </van-button>
        </div>
      </van-form>
    </div>
  </div>
</template>

<script setup lang="ts">
import { showDialog } from "vant";
import { doFinishRegister } from "../../server/register";
import { ref } from "vue";
import { useRouter } from "vue-router";
import { useCounterStore } from "@/stores/counter";
// import { useStore } from "vuex";
let router = useRouter();
// let store = useStore();
let store = useCounterStore();
let value = ref("");

function onSubmit() {
  doFinishRegister({ tel: store.tel, password: value.value }).then(
    (res: any) => {
      console.log(res);
      if (res.code === "200") {
        showDialog({
          title: "注册完成",
          message: "恭喜注册完成",
        }).then(() => {
          router.push("/login");
        });
      }
    }
  );
}
</script>

<style scoped>
.input {
  margin: 10px;
}
</style>
